// pages/firstpage/bankcard/bankcard.js
import {
  ApiRootUrl,IMG_PATH,apiList
} from '../../../config/index.js'
import Dialog from '../../../@vant/weapp/dialog/dialog';
import Toast from '../../../@vant/weapp/toast/toast';
import{
  request
} from "../../../utils/util"
Page({
  /**
   * 页面的初始数据
   */
  data: {
    statusBarHeight:0,
    infoData:{},
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let userinfo=wx.getStorageSync('userinfo')
    let openId=wx.getStorageSync('openId')
    this.getMycard(openId)
    this.setData({
      statusBarHeight:wx.getSystemInfoSync()['statusBarHeight'],
      userinfo:userinfo,
      openId:openId,
    })
  },

  //返回上一页
  backClick(){
    wx.navigateBack()
  },
  getMycard(openId){
    let self = this;
    wx.request({
      url: `${ApiRootUrl}/bankcard/queryMyCardInfo/${openId}`,
      method: 'get',
      success(res) {
        if (res.data.code == 20000) {
          self.setData({
            infoData:res.data.data
          })
        } else {
          Toast({
            duration: 3000,
            forbidClick: true,
            type: 'fail',
            message: res.data.message,
          });
        }
      },
      fail(res) {
        Toast({
          duration: 3000,
          forbidClick: true,
          type: 'fail',
          message: '网络错误',
        });
      }
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})